<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文件管理</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/css/bootstrap.min.css') }}">
    <style>
        header, footer {
            padding: 20px 0;
            text-align: center;
        }
        .content {
            min-height: 300px;
            padding: 20px;
        }
    </style>
</head>
<body>
<div class="container-fluid vh-100 d-flex flex-column">
    <!-- 1. Header 头部 -->
    <header class="bg-primary text-white p-3">
        <h1>会飞的猫二课堂学生文件存储服务</h1>
        <p>欢迎你我的学生 {{ name }}</p>
        <h2><a href="{{ url_for('logout') }}" style="color: white;">退出</a></h2>
    </header>

    <!-- 2. Content 内容区域 -->
    <main class="content flex-grow-1 bg-light">
        <div class="container">
            <button type="button" class="btn btn-success"
                    onclick="window.location.href='{{ url_for('upload_file') }}'">上传</button>
            <h4>已上传存储的文件</h4>
            <table class="table">
                <thead>
                <tr>
                    <th scope="col">序号</th>
                    <th scope="col">文件名</th>
                    <th scope="col">删除</th>
                    <th scope="col">下载</th>
                </tr>
                </thead>
                <tbody>
                {% for file in files %}
                    <tr>
                        <th scope="row" style="width: 80px">{{ loop.index }}</th>
                        <td>{{ file[1] }}</td>
                        <td style="width: 100px">
                            <form action="{{ url_for('delete_file', file_id=file[0]) }}" method="POST" style="display: inline;">
                                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                                <button type="submit" class="btn btn-danger"
                                        onclick="return confirm('确定删除吗？')">删除</button>
                            </form>
                        </td>
                        <td style="width: 100px">
                            <a href="{{ url_for('download_file', filename=file[1]) }}" class="btn btn-primary">下载</a>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </main>

    <!-- 3. Footer 页脚 -->
    <footer class="bg-dark text-white p-3">
        <p>© 2025 为了我的学生在二课堂可以存储代码而写。享受吧孩子们 ，但也别忘了学习！技术会让你们一生傲视群雄</p>
    </footer>
</div>
<script src="{{ url_for('static', filename='bootstrap/js/bootstrap.bundle.min.js') }}"></script>
</body>
</html>